<%@ Page Language="C#" EnableViewState="false" ValidateRequest="false" AutoEventWireup="true" 
	MasterPageFile="~/App_ThemeMasters/NoStyle/AdminOneColumnLayout.Master" Inherits="Syrinx.Gui.AspNet.Nitobi2.NitobiBasePage" %>

<%@ Register Assembly="Swaf.Gui.AspNet2" Namespace="Swaf.Gui.AspNet2" TagPrefix="swf" %>
<%@ Register Assembly="ScsAspNet" Namespace="Syrinx.Gui.AspNet.Nitobi2" TagPrefix="snc" %><%@ Register Assembly="NitobiControls" Namespace="Nitobi" TagPrefix="ntb" %>
<%@ Register Assembly="ScsAspNet" Namespace="Articles.Gui.AspNet" TagPrefix="art" %>
<%@ Register Assembly="UserManagement.Gui.AspNet" Namespace="UserManagement.Gui.AspNet" TagPrefix="usr" %>

<!--#include file="~/SiteControls/RegisterStandardControls.txt"-->
<!--#include file="../SiteControls/StandardHeaderPageContent.inc"-->
<!--#include file="../SiteControls/StandardFooterPageContent.inc"-->

<asp:Content ID="c1" ContentPlaceHolderID="title" runat="server">
	<%SecurityPrivilege="AppFunctions.ManageCompanyConfiguration"; %>
    <div class="left"><h2><asp:label runat="server" ID="_compManagementlbl">Company Management</asp:label></h2></div>
</asp:Content>

<asp:Content ID="c3" ContentPlaceHolderID="mainContent" runat="server">
	<swf:BizProc runat="server" ID="cmp" factoryName="company">
		<ParentBizProc id="loginBP" fieldName="companyId" dataId="id" />
	</swf:BizProc>
    <snc:Combo ID="companyGrid" runat="server"  Mode="Classic" GetDataUrl="NitobiLiveStreamHandler.aspx" ParentBizProcIds="cmp" DataTextField="keyName">
		<TextBox Width="250" />
		<List Width="370" Height="200" />
	    <Columns>
		    <ntb:BoundColumn DataField="id" Visible="false" />
		    <ntb:BoundColumn DataField="keyName" Visible="false" />
		    <ntb:BoundColumn DataField="depthName" HeaderText="Companies" width="300"  />
		    <ntb:BoundColumn DataField="enable" HeaderText="Enable" width="50"  />
	    </Columns>
    </snc:Combo>
    <script type="text/javascript">
	function toggleTabs(cId,c1, dId)
	{
		var a;
		for(i=1; ;i++)
		{
			a = document.getElementById(cId + i);
			b = document.getElementById(dId + i);
			if(a==null || a=='')
				break;
				
			if(i==c1)
			{
				a.className = 'currenttab';
				b.style.display = 'block';
			}
			else
			{
				a.className='';
				b.style.display = 'none';
			}
		}
		
	}
</script>
	<div class="tabs" >
        <div>
		    <ul>
		        <li id="t1" class="currenttab"><div class="firstTab"><swf:DivLayers runat="server" ID="tl1" SkinID="Tab"><asp:HyperLink runat="server" ID="_tabs1" onclick="toggleTabs('t','1','ta')" NavigateUrl="javascript:;" Text="Company Settings"/></swf:DivLayers></div></li>
		        <li id="t2"><swf:DivLayers runat="server" ID="tl2" SkinID="Tab"><asp:HyperLink runat="server" ID="_tabs2" onclick="toggleTabs('t','2','ta')" NavigateUrl="javascript:;" Text="User Groups" /></swf:DivLayers></li>
		        <li id="t3"><div class="lastTab"><swf:DivLayers runat="server" ID="tl3" SkinID="Tab"><asp:HyperLink runat="server" ID="_tabs3" onclick="toggleTabs('t','3','ta')" NavigateUrl="javascript:;" Text="Users" /></swf:DivLayers></div></li>
	        </ul>
        </div>
    </div>
	<div class="clearer"></div>
	<swf:DivLayers ID="mdl1" runat="server" SkinID="MainTabArea">
    <div id="ta1">
		<span class="button1"><snc:ActionButton runat="server" ID="addBtn1" Actions="cmp.AddBizObj" Text="Add" /></span>
		<span class="button6"><snc:ActionButton runat="server" ID="updateBtn1" Actions="cmp.UpdateBizObj" Text="Update" /></span>
		<span class="button1"><snc:ActionButton runat="server" ID="cancelBtn1" Actions="cmp.CancelEdits" Text="Cancel" /></span>
		<span class="button5"><snc:ActionButton runat="server" ID="deleteBtn1" Actions="cmp.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/></span>
		<div>
    		<h3><asp:Label ID="_lmt" runat="server" >Company Limits</asp:Label></h3>
			<snc:NitobiBizObjDisplay ID="limitsDisplay" runat="server" 
				TemplateNameBizRule="getLimitsDisplayTemplate" ParentBizProcIds="cmp"  />
		</div>
		<div id="settings">
			<h3><asp:Label ID="companySettingsLbl" runat="server" >Company Settings</asp:Label></h3>
			<snc:NitobiBizObjDisplay ID="settingsDisplay" runat="server" 
				TemplateNameBizRule="getCompanySettingsDisplayTemplate"
				ParentBizProcIds="cmp" >
			</snc:NitobiBizObjDisplay>
		</div>
	</div>
	<div id="ta2" style="display:none">
	    <swf:BizProc runat="server" ID="ugrp" factoryName="userGroup">
		    <ParentBizProc id="cmp" fieldName="id" dataId="pid" />
	    </swf:BizProc>
		<span class="button1"><snc:ActionButton runat="server" ID="addBtn2" Actions="ugrp.AddBizObj" Text="Add" /></span>
		<span class="button6"><snc:ActionButton runat="server" ID="updateBtn2" Actions="ugrp.UpdateBizObj" Text="Update" /></span>
		<span class="button1"><snc:ActionButton runat="server" ID="cancelBtn2" Actions="ugrp.CancelEdits" Text="Cancel" /></span>
		<span class="button5"><snc:ActionButton runat="server" ID="deleteBtn2" Actions="ugrp.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/></span>
        <div class="clearer"></div>
        <table>
			<tr>
				<td valign="top">
					<snc:Grid ID="companyUserGroup" runat="server" ParentBizProcIds="ugrp"
						Width="330px" Height="200px" ShowToolbar="false" Mode="LiveScrolling"  SelectionMode="Single" AllowSorting="false">
						<Columns>
							<ntb:KeyColumn DataField="id" />
							<ntb:BoundColumn DataField="name" HeaderText="Name" width="100" ReadOnly="false" />
							<ntb:BoundColumn DataField="description" HeaderText="Description" width="225" ReadOnly="false" />
						</Columns>
					</snc:Grid>
				</td>
				<td valign="top">
					<snc:NitobiBizObjDisplay ID="ugDisplay" runat="server" ParentBizProcIds="ugrp"
					EditableTemplate="UserManagement.Gui.AspNet.BasicUserGroupDisplay" />
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<swf:BizProc runat="server" ID="ugrpAF" FactoryName="userGroupAppFunctions">
						<ParentBizProc id="ugrp" dataId="userGroup" />
                		<ParentBizProc id="ugrp" fieldName="appPrivileges" dataId="pid" fullDependency="true" />
                		<ParentBizProc id="ugrp" fieldName="companyId" dataId="mlpid" />
					</swf:BizProc>
					<div class="clearer" style="height:25px;"></div>
					<span class="button1"><snc:ActionButton runat="server" ID="bn5" Actions="ugrpAF.MasterDataOption" Text="Toggle All Security Options" /></span>
					<div class="clearer"></div>
					<snc:Grid ParentBizProcIds="ugrpAF" ID="ugAFGrid" runat="server" mode="LiveScrolling" Width="550px" Height="300px" ShowToolbar="false" ShowCellToolTips="true" SelectionMode="Single" AllowSorting="false" Resizable="Both">
						<Columns>
								<ntb:KeyColumn DataField="id" />
								<ntb:BoundColumn DataField="nitDesc" HeaderText="Name" width="450"  />
								<ntb:ComboColumn DataField="privilege" HeaderText="Privilege" width="85" ValueField="id" DataSourceId="getPrivilegeLevels" GetDataUrl="/NitobiLiveStreamHandler.aspx" ReadOnly="false">
									<ntb:BoundColumn DataField="id" Visible="false" />
									<ntb:BoundColumn DataField="name" />
								</ntb:ComboColumn>
						</Columns>	
					</snc:Grid>
				</td>
			</tr>
        </table>
	</div>
	
	<div id="ta3" style="display:none">
	    <swf:BizProc runat="server" ID="usr" factoryName="user">
		    <ParentBizProc id="cmp" fieldName="id" dataId="pid" />
	    </swf:BizProc>
		<span class="button1"><snc:ActionButton runat="server" ID="addBtn3" Actions="usr.AddBizObj" Text="Add" /></span>
		<span class="button6"><snc:ActionButton runat="server" ID="updateBtn3" Actions="usr.UpdateBizObj,uuGrp.UpdateBizObj" Text="Update" /></span>
		<span class="button1"><snc:ActionButton runat="server" ID="cancelBtn3" Actions="usr.CancelEdits" Text="Cancel" /></span>
		<span class="button5"><snc:ActionButton runat="server" ID="deleteBtn3" Actions="usr.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/></span>
        <div class="clearer"></div>
        <snc:Grid ID="companyUsers" runat="server" ParentBizProcIds="usr"
            Width="330px" Height="200px" ShowToolbar="false" Mode="LiveScrolling" SelectionMode="Single" AllowSorting="false" Resizable="Both">
            <Columns>
                <ntb:KeyColumn DataField="id" />
                <ntb:BoundColumn DataField="userName" HeaderText="Login Name" width="110" />
                <ntb:BoundColumn DataField="contact.fullName" HeaderText="Name" width="200" />
            </Columns>
        </snc:Grid>
	    <div class="clearer" style="height:25px"></div>
        <snc:NitobiBizObjDisplay ID="userDetail" runat="server" Width="100%" 
			EditableTemplate="UserManagement.Gui.AspNet.UserDisplay,Contacts.Gui.AspNet.BasicContactDisplay" ParentBizProcIds="usr" />
		<h3><asp:Label ID="_limitLbl" runat="server" Text="User Limits" /></h3>
		<snc:NitobiBizObjDisplay ID="us2" runat="server"
		TemplateNameBizRule="getUserLimitsDisplayTemplate" ParentBizProcIds="usr" />
		
		<swf:BizProc id="uuGrp"	runat="server" FactoryName="userUserGroups">
			<ParentBizProc id="usr" fieldName="id" dataId="pid" />
			<ParentBizProc id="usr" fieldName="companyId" dataId="mlpid" />
		</swf:BizProc>
		<div class="clearer" style="height:5px;"></div>
		<span class="button1"><snc:ActionButton runat="server" ID="ab6" Actions="uuGrp.MasterDataOption" Text="Toggle All Security Options" /></span>
		<br /><br />
		<snc:ComplexBizObjListDisplay ID="usrUsrGroupsDisplay" runat="server" ParentBizProcIds="uuGrp"
			ReadOnlyTemplate="UserManagement.Gui.AspNet.UserUserGroupsListDisplay"  >
		</snc:ComplexBizObjListDisplay>		
    </div>    
    </swf:DivLayers>
 
</asp:Content>